var errormsg="";
function checkEmail(mail,name)
{
   email=mail.value;
	var at1      =  email.indexOf("@");
   var at2      =  email.lastIndexOf("@");
   var dot     =  email.lastIndexOf(".");
   var space   =  email.indexOf(" ");
   if((at1!=-1)&&
      (at1!=0)&&
      (at2==at1)&&
      (dot!=-1)&&
      (dot>at1+1)&&
      (dot<email.length-1)&&
      (space==-1))
   {
      return true;
   }
   else
   {
      alert("- "+name);
		mail.focus();
      return false;
   }
}
function checkTextField(str,name)
{
	if(str.value=="")
	{
		alert("- "+name);		
		str.focus();
		return false;
	}
	else
		return true;
}
function checkSelection(str,name,index)
{
	if(str.selectedIndex==index)
	{
		alert("- "+name);		
		str.focus();
		return false;
	}
	else
		return true;
}

function checkPassword(p,rp,name)
{
	if(p.value!="" && rp.value!="" && p.value==rp.value)
	{
		return true;
	} 	
	else
	{
		alert("- "+name);
		if(p.value=="")
		{
			p.focus();
		}
		if(rp.value=="")
		{
			rp.focus();	
		}
		if(p.value!='')
		{
			rp.select();
			rp.focus();	
		}
		return false;
	}
}
function setCheckboxes(the_form, the_box, do_check)
{
    var elts      = (typeof(document.forms[the_form].elements[the_box]) != 'undefined')
                  ? document.forms[the_form].elements[the_box]
                  : document.forms[the_form].elements[the_box];
    var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;

    if (elts_cnt) {
        for (var i = 0; i < elts_cnt; i++) {
            elts[i].checked = do_check;
        }
    } else {
        elts.checked        = do_check;
    }
    return true;
}

function checkCheckboxes(the_form, the_box)
{
   var elts      = (typeof(document.forms[the_form].elements[the_box]) != 'undefined')
                  ? document.forms[the_form].elements[the_box]
                  : document.forms[the_form].elements[the_box];
   var elts_cnt  = (typeof(elts.length) != 'undefined')
                  ? elts.length
                  : 0;
	err=false;

	if (elts_cnt)
   {
		for (var i = 0; i < elts_cnt; i++)
		{
			if(elts[i].checked == true)
			{
				err=true;
				break;
			}
		}

	}
	else if(document.forms[the_form].elements[the_box].checked==true)
	{
		err=true;
	}

	return err;
}